import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/*
 *@Student 张策
 */
public class PrivateTest {
    private String name="hello";

    public String getName(String a) {
        return a;
    }
    @Override
    public String toString() {
        return "PrivateTest{" +
                "name='" + name + '\'' +
                '}';
    }
}
class Mains{
    public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, InstantiationException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
        Class<?> aClass = Class.forName("PrivateTest");
        Object object = aClass.newInstance();
        Field name = aClass.getDeclaredField("name");
        name.setAccessible(true);
        System.out.println(name.get(object));
        name.set(object,"666");
        System.out.println(name.get(object));
        Method method = aClass.getMethod("getName",String.class);
        System.out.println(method.invoke(object,"777"));
        Class<?> aClass1 = Class.forName("java.io.File");
        Constructor<?> constructor = aClass1.getConstructor(String.class);
        Object object1 = constructor.newInstance("e:\\a.txt");
        File file = new File();
        System.out.println(object1.getClass());
    }
}
